﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScheduleMaker.ConfigManager;
using ScheduleMaker.DB.Domain;
using ScheduleMaker.DB.Domain.Core;
using ScheduleMaker.DB.CoreDAO;

namespace ScheduleMaker.DB
{
    public class DAOFactory
    {
        public static ClassHourDAO classHourDAOSchool;
        public static ClassHourDAO classHourDAOUniversity;
        public static UserDAO userDAOSchool;
        public static UserDAO userDAOUniversity;
        public static TeacherDAO teacherDAOSchool;
        public static TeacherDAO teacherDAOUniversity;
        public static LevelDAO levelDAOSchool;
        public static LevelDAO levelDAOUniversity;
        public static ClassroomDAO classroomDAOSchool;
        public static ClassroomDAO classroomDAOUniversity;
        public static DayDAO dayDAOSchool;
        public static DayDAO dayDAOUniversity;
        public static EquipmentDAO equipmentDAOSchool;
        public static EquipmentDAO equipmentDAOUniversity;
        public static HourDAO hourDAOSchool;
        public static HourDAO hourDAOUniversity;
        public static SubjectDAO subjectDAOShool;
        public static SubjectDAO subjectDAOUniversity;
        public static ScheduleDAO scheduleDAOSchool;
        public static ScheduleDAO scheduleDAOUniversity;
        public static EmergencyScheduleDAO emergencyScheduleDAOSchool;
        public static EmergencyScheduleDAO emergencyScheduleDAOUniversity;
        public static GroupDAO groupDAOSchool;
        public static CategoryDAO categoryDAOUniversity;
        public static ClassroomUnavailabilityDAO classroomUnavailabilityDAOSchool;
        public static ClassroomUnavailabilityDAO classroomUnavailabilityDAOUniversity;
        public static TeacherUnavailabilityDAO teacherUnavailabilityDAOSchool;
        public static TeacherUnavailabilityDAO teacherUnavailabilityDAOUniversity;

        static DAOFactory()
        {
            classHourDAOSchool = new ClassHourDAO(new ClassHourDAOSchool());
            classHourDAOUniversity = new ClassHourDAO(new ClassHourDAOUniversity());
            userDAOSchool = new UserDAO(new UserDAOSchool());
            userDAOUniversity = new UserDAO(new UserDAOUniversity());
            teacherDAOSchool = new TeacherDAO(new TeacherDAOSchool());
            teacherDAOUniversity = new TeacherDAO(new TeacherDAOUniversity());
            levelDAOSchool = new LevelDAO(new LevelDAOSchool());
            levelDAOUniversity = new LevelDAO(new LevelDAOUniversity());
            classroomDAOSchool = new ClassroomDAO(new ClassroomDAOSchool());
            classroomDAOUniversity = new ClassroomDAO(new ClassroomDAOUniversity());
            dayDAOSchool = new DayDAO(new DayDAOSchool());
            dayDAOUniversity = new DayDAO(new DayDAOUniversity());
            equipmentDAOSchool = new EquipmentDAO(new EquipmentDAOSchool());
            equipmentDAOUniversity = new EquipmentDAO(new EquipmentDAOUniversity());
            hourDAOSchool = new HourDAO(new HourDAOSchool());
            hourDAOUniversity = new HourDAO(new HourDAOUniversity());
            subjectDAOShool = new SubjectDAO(new SubjectDAOSchool());
            subjectDAOUniversity = new SubjectDAO(new SubjectDAOUniversity());
            scheduleDAOSchool = new ScheduleDAO(new ScheduleDAOSchool());
            scheduleDAOUniversity = new ScheduleDAO(new ScheduleDAOUniversity());
            emergencyScheduleDAOSchool = new EmergencyScheduleDAO(new EmergencyScheduleDAOSchool());
            emergencyScheduleDAOUniversity = new EmergencyScheduleDAO(new EmergencyScheduleDAOUniversity());
            groupDAOSchool = new GroupDAO(new GroupDAOSchool());
            categoryDAOUniversity = new CategoryDAO(new CategoryDAOUniversity());
            classroomUnavailabilityDAOSchool = new ClassroomUnavailabilityDAO(new ClassroomUnavailabilityDAOSchool());
            classroomUnavailabilityDAOUniversity = new ClassroomUnavailabilityDAO(new ClassroomUnavailabilityDAOUniversity());
            teacherUnavailabilityDAOSchool = new TeacherUnavailabilityDAO(new TeacherUnavailabilityDAOSchool());
            teacherUnavailabilityDAOUniversity = new TeacherUnavailabilityDAO(new TeacherUnavailabilityDAOUniversity());
        }

        public static ClassHourDAO getClassHourDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return classHourDAOSchool;
                case Mode.University:
                    return classHourDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static UserDAO getUserDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return userDAOSchool;
                case Mode.University:
                    return userDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static TeacherDAO getTeacherDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return teacherDAOSchool;
                case Mode.University:
                    return teacherDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static LevelDAO getLevelDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return levelDAOSchool;
                case Mode.University:
                    return levelDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static ClassroomDAO getClassroomDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return classroomDAOSchool;
                case Mode.University:
                    return classroomDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static DayDAO getDayDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return dayDAOSchool;
                case Mode.University:
                    return dayDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static EquipmentDAO getEquipmentDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return equipmentDAOSchool;
                case Mode.University:
                    return equipmentDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static HourDAO getHourDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return hourDAOSchool;
                case Mode.University:
                    return hourDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static SubjectDAO getSubjectDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return subjectDAOShool;
                case Mode.University:
                    return subjectDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static ScheduleDAO getScheduleDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return scheduleDAOSchool;
                case Mode.University:
                    return scheduleDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static EmergencyScheduleDAO getEmergencyScheduleDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return emergencyScheduleDAOSchool;
                case Mode.University:
                    return emergencyScheduleDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static GroupDAO getGroupDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return groupDAOSchool;
                case Mode.University:
                    //TODO: lepiej rzucic wyjatkiem
                    return null;
                default:
                    throw new UnknownModeException();
            }
        }

        public static CategoryDAO getCategoryDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return null;
                case Mode.University:
                    return categoryDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static ClassroomUnavailabilityDAO getClassroomUnavailabilityDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return classroomUnavailabilityDAOSchool;
                case Mode.University:
                    return classroomUnavailabilityDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }

        public static TeacherUnavailabilityDAO getTeacherUnavailabilityDAO(Mode mode)
        {
            switch (mode)
            {
                case Mode.School:
                    return teacherUnavailabilityDAOSchool;
                case Mode.University:
                    return teacherUnavailabilityDAOUniversity;
                default:
                    throw new UnknownModeException();
            }
        }
    }
}
